'use strict';
exports = module.exports = function($scope, $timeout) {
    var objinit = function(){
        $scope.obj = { key: '', type: '', count: '' };
    };
    objinit();
    $scope.list = [
        { key: 'id', type: 'number', count: '1-3' },
        { key: 'key', type: 'string', count: '5-10' },
        { key: 'name1', type: 'name', count: '2-3' },
        { key: 'name2', type: 'cname', count: '' },
        { key: 'birthday', type: 'date', count: '' },
        { key: 'msg', type: 'chinese', count: '15-20' },
        { key: 'url', type: 'url', count: '' },
        { key: 'city', type: 'city', count: '' }
    ];
    $scope.add = function(){
        $scope.list.push(angular.copy($scope.obj));
        objinit();
    };
    $scope.reset = function(){
        $scope.list = [];
        objinit();
        m1init();
    };
    $scope.make = function(){
        var Random = Mock.Random;
        var d = [];
        for(var i = 0, l = 10; i < l; i++){
            var ooo = {};
            console.log($scope.list)
            for(var li = 0, ll = $scope.list.length; li < ll; li++){
                var param = $scope.list[li];
                if(param.type == "number") {
                    //Random.string('number', 5);/*随机选5个数字*/
                    ooo[param.key] = Random.string('number', param.count.split("-")[0], param.count.split("-")[1]);
                } else if(param.type == "string"){
                    //Random.word(5);/*随机5个字母随便的单词*/
                    //Random.word(3, 5);/*随机3-5个字母随便的单词*/
                    ooo[param.key] = Random.word(param.count.split("-")[0], param.count.split("-")[1]);
                } else if(param.type == "chinese"){
                    //Random.csentence(5);/*随机5个汉字随便的中文*/
                    //Random.csentence(3, 5);/*随机3-5个汉字随便的中文*/
                    ooo[param.key] = Random.csentence(param.count.split("-")[0], param.count.split("-")[1]).replace('。','');
                } else if(param.type == "date"){
                    //Random.datetime('y-MM-dd HH:mm:ss');/*随机日期16-02-25 12:56:33*/
                    ooo[param.key] = Random.datetime('yyyy/MM/dd HH:mm:ss');
                } else if(param.type == "city"){
                    //Random.county(true);/*"广东省 潮州市 潮安区"*/
                    ooo[param.key] = Random.county(true);
                } else if(param.type == "cname"){
                    //Random.cname();/*"随机中文全名"*/
                    ooo[param.key] = Random.cname();
                } else if(param.type == "name"){
                    //Random.name();/*"随机英文名"*/
                    ooo[param.key] = Random.name();
                } else if(param.type == "url"){
                    //Random.url();/*"随机网址"*/
                    ooo[param.key] = Random.url();
                } else if(param.type == "email"){
                    //Random.email();/*"随机邮箱"*/
                    ooo[param.key] = Random.email();
                } else if(param.type == "ip"){
                    //Random.ip();/*"随机ipv4"*/
                    ooo[param.key] = Random.ip();
                } else if(param.type == "guid"){
                    //Random.guid();/*"guid"*/
                    ooo[param.key] = Random.guid();
                } else {
                    //Random.word();/*随机随便的单词*/
                    ooo[param.key] = Random.word();
                }
            }
            d.push(ooo);
        }
        $timeout(function(){ $scope.m1 = d; });

    };
    var m1init = function(){
        $scope.m1 = {};
    };
    m1init();
    //Random.string('lower', 5);/*随机选5个小写字母*/
    //Random.string('upper', 5);/*随机选5个大写字母*/
    //Random.string(5);/*随机5个字符*/
    //Random.string('symbol', 5);/*随机选5个符号*/
    //Random.string('aeiou', 5);/*特定字符中随机选5个可重复*/
    //Random.string('lower', 1, 3);/*随机选1-3个 同上*/
    //Random.date('yyyy-MM-dd');/*随机日期1994-07-19*/
    //Random.date('yy-MM-dd');/*随机日期84-04-22*/
    //Random.time('a HH:mm:ss');/*随机日期am 09:55:45*/
    //Random.time('HH:mm:ss');/*随机日期15:54:58*/
    //Random.datetime('yy-MM-dd a HH:mm:ss');/*随机日期94-08-07 am 09:51:42*/
    //Random.sentence(5);/*随机5个随便的单词*/
    //Random.sentence(3, 5);/*随机3-5个随便的单词*/
    //Random.cparagraph(1);/*随机1行随便的中文*/
    //Random.cparagraph(1, 3);/*随机1-3行随便的中文*/
    //Random.domain();/*"随机域名"*/
    //Random.first();/*"随机英文首名"*/
    //Random.last();/*"随机英文尾名"*/
    //Random.cfirst();/*"随机中文姓氏"*/
    //Random.clast();/*"随机中文名"*/
    //Random.province();/*"广东省"*/
    //Random.city();/*"潮州市"*/
    //Random.city(true);/*"广东省 潮州市"*/
    //Random.county();/*"潮安区"*/
}